// 封装sku模块数据接口
import request from '@/utils/request'
import type { AddSkuParams, SkuListResponse,SkuAllListResponse,SkuDetailResponse} from '@/types/product/sku'

// 添加sku数据
export const addSkuAPI = (data: AddSkuParams) => {
    return request.post<any,any>('/admin/product/saveSkuInfo',data)
}

// 查询某一个spu下所有的sku数据-在spu管理模块中简易查看数据
export const getSkuListAPI = (spuId:number | string) => {
    return request.get<any,SkuListResponse>(`/admin/product/findBySpuId/${spuId}`)
}

// 查询所有sku数据列表
export const getAllSkuListAPI = (page: number, limit: number) => {
    return request.get<any,SkuAllListResponse>(`/admin/product/list/${page}/${limit}`)
}

// 商品上架
export const onSaleAPI = (skuId: number | string) => {
    return request.get<any,any>(`/admin/product/onSale/${skuId}`)
}

// 商品下架
export const cancelSaleAPI = (skuId: number | string) => {
    return request.get<any,any>(`/admin/product/cancelSale/${skuId}`)
}

// 获取sku详情信息
export const getSkuDetailAPI = (skuId: number | string) => {
    return request.get<any,SkuDetailResponse>(`/admin/product/getSkuInfo/${skuId}`)
}

// 删除商品sku
export const deleteSkuAPI = (skuId: number | string) => {
    return request.delete<any,any>(`/admin/product/deleteSku/${skuId}`)
}